﻿
@using System.Data;
@using Webdiyer.WebControls.Mvc;
@{
    Layout = null;
}
@model  PagedList<DataRow>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>列表</title>
    <link href="~/Content/admin/css/bootstrap.min.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.10.2.min.js"></script>


    <script src="~/Content/My97DatePicker/WdatePicker.js"></script>
    <script src="~/Content/MvcPager/MvcPager.js"></script>
    <script src="~/Content/admin/js/bootstrap.min.js"></script>

    <script src="~/Content/kindeditor/kindeditor-all-min.js"></script>
    <script src="~/Content/kindeditor/lang/zh_CN.js"></script>

    <style>
        .pibarea {
            float: left;
            margin-left: 2em;
        }
    </style>
</head>
<body>
    <ol class="breadcrumb">
        <li><a href="/set/admin/center">首页></a></li>
        <li><a href="#">系统通知></a></li>
        <li class="active">联盟公告</li>
    </ol>
    <div class="container-fluid">
        <div class="portlet-body">
            @Html.Partial("_Add")
            <form class="navbar-form navbar-left" id="formSearch" role="form" action="/SystemNotic/Announcement/List" style="padding:0 0;">
                <a class="btn btn-primary btn-sm " data-toggle="modal" href="javascript:void(0);" onclick="Add();"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span>&nbsp;发公告</a>
                <div class="form-group">
                    <input type="text" class="form-control input-sm" id="SearchTitle" name="title" placeholder="请输入公告标题" />
                    <input type="text" class="form-control input-sm" name="TimeFrom" id="OperateTimeFrom" placeholder="发布时间" onclick="WdatePicker();" />
                    至
                    <input type="text" class="form-control input-sm" name="TimeTo" id="OperateTimeTo" placeholder="发布时间" onclick="WdatePicker({ minDate: '#F{$dp.$D(\'OperateTimeFrom\')}' });" />
                </div>
                <button type="submit" class="btn btn-primary btn-sm ">
                    <span class="glyphicon glyphicon-zoom-in" aria-hidden="true"></span>&nbsp;搜索
                </button>

            </form>
            <div id="divTable">
                <table class="table table-bordered  table-condensed table-condensed  table-hover">
                    <thead>
                        <tr>
                            <th>发布时间</th>
                            <th>公告标题</th>
                            <th>阅读人数</th>
                            <th>发布人</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var row in Model)
                        {
                            <tr>
                                <td class="title">
                                    @Convert.ToDateTime(row["CreateTime"]).ToString("yyyy-MM-dd HH:mm:ss")
                                </td>
                                <td>@row["Title"]</td>
                                <td>@row["ReadCount"]</td>
                                <td>@row["UserAccount"]</td>
                                <td>
                                    <a class="btn btn-default btn-xs" title='' onclick="Delete('@row["Guid"]','@row["title"]');">删除 </a>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>

                <input type="hidden" value="@Model.TotalPageCount" id="TotalPageCount" />
                <ul class="pagination">
                    <li>
                        <span aria-hidden="true">
                            @(Model.PageSize)条/页，@(Model.TotalPageCount)页, 共@(Model.TotalItemCount)条
                        </span>
                    </li>

                    <li>
                        <span aria-hidden="true">
                            每页
                            <select style="border-radius:4px;font-family:normal;vertical-align: text-bottom;" id="PageSize" name="PageSize" onchange="PageSizeChange();">
                                <option value="10">10</option>
                                <option value="15">15</option>
                                <option value="20">20</option>
                            </select>
                            条
                        </span>
                    </li>
                </ul>
                @Ajax.Pager(Model,
new PagerOptions
{
    PageIndexParameterName = "id",
    CssClass = "pagination",
    FirstPageText = "首页",
    LastPageText = "尾页",
    PrevPageText = "上一页",
    PageIndexBoxId = "pageIndexBox",
    NextPageText = "下一页",
    CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
    DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
    PagerItemTemplate = "<li>{0}</li>",
    AutoHide = false,

}, new MvcAjaxOptions
{
    UpdateTargetId = "divTable",
    HttpMethod = "Post",
    DataFormId = "formSearch",
    EnableHistorySupport = false,
    //OnSuccess = "EditMsg",
    EnablePartialLoading = true
}
)
                <div class="pagination" style="width:20%;margin-top: 0px;">
                    <ul class="pagination">
                        <li>
                            <div class="input-group">
                                <span class="input-group-addon" id="sizing-addon2">第</span>
                                <input type="text" id="pageIndexBox" class="form-control input-sm" placeholder="" aria-describedby="sizing-addon2" oninput="InputPageIndex(this);">
                                <span class="input-group-addon">页</span>
                                <span class="input-group-btn">
                                    <button class="btn btn-primary btn-sm" type="button" onclick="GoPageIndex();">GO</button>
                                </span>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        @section Scripts{
            @{Html.RegisterMvcPagerScriptResource();}
        }

        <script type="text/javascript">
            function InputPageIndex(obj) {
                var pageIndex = $(obj).val().trim();
                if (parseInt(pageIndex) > parseInt($("#TotalPageCount").val())) {
                    $(obj).val($("#TotalPageCount").val());
                }
            }
            function GoPageIndex() {
                var pager = Webdiyer.MvcPagers[0];
                var pageIndex = $("#pageIndexBox").val().trim();
                var TotalPageCount = $("#TotalPageCount").val().trim();
                if (parseInt(pageIndex) > parseInt(TotalPageCount)) {
                    pageIndex = TotalPageCount;
                }
                if (pager != null) {
                    pager.goToPage(parseInt(pageIndex));
                } else
                { alert("找不到指定的MvcPager！"); }

            }
        </script>
    </div>

    <script>
            function Add() {
                $("#Title").val("").focus();
                $("#Add").modal('show');
            }

            KindEditor.ready(function (K) {
                K.each({
                    'plug-align': {
                        name: '对齐方式',
                        method: {
                            'justifyleft': '左对齐',
                            'justifycenter': '居中对齐',
                            'justifyright': '右对齐'
                        }
                    },
                    'plug-order': {
                        name: '编号',
                        method: {
                            'insertorderedlist': '数字编号',
                            'insertunorderedlist': '项目编号'
                        }
                    },
                    'plug-indent': {
                        name: '缩进',
                        method: {
                            'indent': '向右缩进',
                            'outdent': '向左缩进'
                        }
                    }
                }, function (pluginName, pluginData) {
                    var lang = {};
                    lang[pluginName] = pluginData.name;
                    KindEditor.lang(lang);
                    KindEditor.plugin(pluginName, function (K) {
                        var self = this;
                        self.clickToolbar(pluginName, function () {
                            var menu = self.createMenu({
                                name: pluginName,
                                width: pluginData.width || 100
                            });
                            K.each(pluginData.method, function (i, v) {
                                menu.addItem({
                                    title: v,
                                    checked: false,
                                    iconClass: pluginName + '-' + i,
                                    click: function () {
                                        self.exec(i).hideMenu();
                                    }
                                });
                            })
                        });
                    });
                });
                K.create('#contentqq', {
                    themeType: 'qq',
                    items: [
                        'bold', 'italic', 'underline', 'fontname', 'fontsize', 'forecolor', 'hilitecolor', 'plug-align', 'plug-order', 'plug-indent', 'link'
                    ], afterBlur: function () { this.sync(); }
                });
                K.html('#contentqq', "");

            });
            function Delete(obj, title) {
                parent.layer.confirm('确定要删除【' + title + '】吗?', {
                    title: "提示", icon: 3,
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    $.post("/SystemNotic/Announcement/delete", { Guids: obj }, function (data) {
                        parent.layer.closeAll('dialog'); //关闭信息框
                        if (data.succ) {
                            $("#formSearch").submit();
                            //  window.location.reload();
                        } else {
                            parent.layer.alert(data.msg, { title: "提示", icon: 5, time: 5000 });
                        }

                    })
                }, function () { });
            }
    </script>
</body>
</html>
